<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<s:url action="tree!listFoldenTree" namespace="/system"
	var="listFoldenTree"></s:url>
<script type="text/javascript">
	var path="${pageContext.request.contextPath}";
	var listFoldenTree="${listFoldenTree}";
	function selectType(obj){
		var radios=document.getElementsByName("treeNode\.type");
		if(radios.length==2){
			if(radios[0].checked){
				//选择链接时候
				document.getElementsByName("treeNode\.leaf")[0].value="true";
				document.getElementById("linkInputDiv").style.display="block";
			}
			if(radios[1].checked){
				//选择文档时候
				document.getElementsByName("treeNode\.leaf")[0].value="false";
				document.getElementById("linkInputDiv").style.display="none";
			}			
		}
	}
	function changeFormDataByType(){
		//如果选择链接的时候
		var radios=document.getElementsByName("treeNode\.type");
		if(radios.length==2){
			if(radios[1].checked){
				//选择链接时候
				document.getElementsByName("treeNode\.target")[0].value="";
				document.getElementsByName("treeNode\.url")[0].value="";
			}
		}
		return true;
	}
</script>
<!-- 会员管页面页面 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<link href="${pageContext.request.contextPath}/pages/admin/css/main.css"
	rel="stylesheet" type="text/css" />
<body>

	<div class="tform">
		<!-- 操作按钮位置 -->
		<!--<s:url action="%{actionName}!list" namespace="/admin"
			var="entityListLink"></s:url>
		<button type='button' class="btn1"
			onClick="location='${entityListLink}';">
			<s:property value="%{getText('common.text.back')}" />
		</button>
		-->
		<!-- <button type='button' class="btn1" onClick="location='content_list.php?cid={dede:global.cid/}&mid=<?php echo $cuserLogin->getUserID(); ?>';">我的数据</button>        
        <button type='button' class="btn1" onClick="location='catalog_main.php';">栏目管理</button>
        <button type='button' class="btn1" name='bb1' onClick="location='makehtml_list.php?cid={dede:global.cid/}';">更新列表</button>
        <button type='button' class="btn1" name='bb2' onClick="location='makehtml_archives.php?cid={dede:global.cid/}';">更新数据</button>
        <button type='button' class="btn1" name='bb1' onClick="location='recycling.php?cid={dede:global.cid/}';">文章回收站</button>
         -->
	</div>

	<div>
		<s:form method="post">
			<s:hidden key="treeNode.id" />
			<s:hidden key="treeNode.leaf" value="%{true}" />

			<s:if test="treeNode!=null">
				<s:textfield key="treeNode.text" autocomplete="off" />
				<s:textfield key="treeNode.belongTo.text" readonly="true"
					disabled="true" />
				<s:hidden name="treeNode.belongTo.id" />
				<!-- 修改时候 -->
				<s:if test="treeNode.leaf">
					<!-- 是枝叶-->
					<s:radio key="treeNode.type" list="nodeTypeMap" listKey="key"
						listValue="value" value="treeNode.type" onclick="selectType(this)"></s:radio>
					<div id="linkInputDiv">
						<s:textfield key="treeNode.target" autocomplete="off" />
						<s:textfield key="treeNode.url" autocomplete="off" />
					</div>
				</s:if>
				<s:else>
					<s:textfield key="treeNode.type.value" readonly="true"
						disabled="true" />
				</s:else>
			</s:if>
			<s:else>
				<!-- 新增时 -->
				<s:textfield key="treeNode.text" autocomplete="off" />
				<s:hidden name="treeNode.belongTo.id" value="%{belongTo.id}" />
				<s:textfield key="treeNode.belongTo.text" value="%{belongTo.text}"
					readonly="true" disabled="true" />
				<s:radio key="treeNode.type" list="nodeTypeMap" listKey="key"
					listValue="value" value="%{'LINK'}" onclick="selectType(this)"></s:radio>
				<div id="linkInputDiv">
					<s:textfield key="treeNode.target" autocomplete="off" />
					<s:textfield key="treeNode.url" autocomplete="off" />
				</div>
			</s:else>

			<s:if test="treeNode==null">
				<s:submit key="common.text.save" cssClass="btn1"
					action="%{actionName}!save" namespace="%{nameSpace}" />
			</s:if>
			<s:else>
				<s:if test="!treeNode">
					<s:submit key="common.text.add" cssClass="btn1"
						action="%{actionName}!form">
					</s:submit>
				</s:if>
				<s:submit key="common.text.update" cssClass="btn1"
					action="%{actionName}!update"
					onclick="return changeFormDataByType();" />
			</s:else>

		</s:form>
	</div>
</body>
</html>